package org.raymond.iworks.study.basic.designpattern.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author raymond
 * @version V1.0
 * @Description: TODO
 */
public class University extends OrganizationComponent{
    // 这里包含的是college,实际业务中,university添加college与college添加department的业务逻辑很可能是不一样的.
    // 因此这里分成两个University和College类也没问题
    private List<OrganizationComponent> componentList = new ArrayList<>();
    public University(String name, String des) {
        super(name, des);
    }

    @Override
    protected void add(OrganizationComponent component) {
        componentList.add(component);
    }

    @Override
    protected void remove(OrganizationComponent component) {
        componentList.remove(component);
    }

    @Override
    protected void print() {
        System.out.println("===="+getName()+"====");
        for(OrganizationComponent component : componentList){
            component.print();
        }
    }
}
